﻿@model MSAcademic.v2.Web.Areas.Admin.Models.Article.ArticlePreviewModel

@{
    ViewBag.Title = Model.Article.Title;
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<script src="~/Scripts/waypoints.min.js"></script>
<script type="text/javascript">
    $(function () {
        var headers         =   $('h2'),
            headerJmpList   =   $('.sidebar .ui-jump-list');
        
        /* Generates a jumpList for h2 elems in the article */
        msacademic.jumpListFor(headers, headerJmpList);

        /* Bind header waypoints */
        headers.waypoint(function (event, direction) {
            var jmpItemId = $(this).attr("jumpId"),
                jmpItem = headerJmpList.find('[jumpId="' + jmpItemId + '"]');

            headerJmpList.find('li').removeClass('active');
            
            if(direction === "down") {
                jmpItem.addClass('active');
            } else {
                jmpItem.prev().addClass('active');
            }
        }, { offset: '10%' });

        /* Make the jump list sticky */
        $('.articleBody .sidebar .ui-jump-list').waypoint(function (event, direction) {
		    $(this).parent().toggleClass('sticky', direction === "down");
		    event.stopPropagation();
        });

        $('.article .facebook-integration').waypoint(function (event, direction) {
            if(direction === "down") {
                headerJmpList.parent().removeClass('sticky').addClass('bottom-reached');
            } else {
                headerJmpList.parent().removeClass('bottom-reached').addClass('sticky');
            }
        }, {
            offset: 330
        });

    });
</script>

<div class="article">

    <h1 class="big-title">@Model.Article.Title</h1>
    <div class="date-time">
        Piše @Html.RouteLink(Model.Author.FirstName + " " + Model.Author.LastName, "ViewAuthorProfile", new { authorId = Model.Author.Id }) - 
        @(Model.Article.PublishedOn.HasValue 
            ?  @Model.Article.PublishedOn.Value.ToString("dd. MMMM yyyy. u H:m")  
            : "Članak nije objavljen")
    </div>
    
    <div class="short-text">
        @Html.Raw(Model.Article.ShortText)
    </div>

    <div class="author">
        <a href="@Url.RouteUrl("ViewAuthorProfile", new { authorId = Model.Author.Id })">
            <img src="@Model.Author.ProfilePictureUrl" />
            <div class="disc"></div>
        </a>
    </div>

    <div class="image-mirrorlete clearfix">
        <div class="full"> <img src="@Model.Article.PictureUrlNormal" alt="@Model.Article.Title" /> </div>
        <div class="semi"> <img src="@Model.Article.PictureUrlNormal" alt="@Model.Article.Title" /> </div>
        <div class="light"> <img src="@Model.Article.PictureUrlNormal" alt="@Model.Article.Title" /> </div>
    </div>

    <div class="articleBody clearfix">
        <div class="sidebar">
            <div class="sidebar-content">
                <div class="ui-jump-list"></div>
                <div class="meta">
                    <a href="@Url.RouteUrl("ViewAuthorProfile", new { authorId = Model.Author.Id })"> @Model.Author.FirstName @Model.Author.LastName </a>  <br />
                    @Model.Article.LongText.Length HTML znakova
                </div>
            </div>
        </div>
        <div class="long-text"> 
            <div class="wrap">
                <h2 class="hidden">Idi na vrh </h2>
                @Html.Raw(Model.Article.LongText) 
                <h2 class="hidden">Komentari</h2>
            </div>
        </div>
    </div>
</div>